package com.aspose.cells;

class zawn extends zawk {
   private int f;
   private int g;
   private zfv h = new zfv();
   private boolean i = false;
   private int j = -1;
   private int k = -1;
   private zafu l;
   private zahr m;
   private int n = -1;

   public zawn(zaay var1, Worksheet var2, int var3, int var4, int var5) {
      super(var1, var2);
      this.l = var2.getCells().getRows().a;
      this.h.a = (short)var3;
      this.f = var4;
      this.g = var5;
   }

   public zahn b(zaay var1) {
      zawn var2 = new zawn(this.b, this.a, this.h.a, this.f, this.g);
      var2.a(this);
      var2.n = this.n;
      if (this.i) {
         var2.j = this.j;
         var2.k = this.k;
         if (this.k > -1) {
            this.m = this.l.a(this.f + this.j, this.f + this.k, false);
         }
      }

      return var2;
   }

   public int c() {
      return this.g - this.f + 1;
   }

   public int d() {
      return 1;
   }

   public int e() {
      return this.c();
   }

   public boolean l() {
      return false;
   }

   public boolean m() {
      return false;
   }

   public boolean n() {
      return true;
   }

   public zfv c(int var1, int var2) {
      if (this.i) {
         if (var1 < this.j || var1 > this.k) {
            return null;
         }

         if (this.j == this.k) {
            return this.c;
         }
      }

      return this.l.a(this.f + var1, this.h, this.e);
   }

   public zagu a(int var1, int var2) {
      if (this.i) {
         if (var1 < this.j || var1 > this.k) {
            return zzk.a;
         }

         if (this.j == this.k) {
            if (this.d != null) {
               return this.d;
            }

            this.d = this.C();
            return this.d;
         }
      }

      zfv var3 = this.l.a(this.f + var1, this.h, 4);
      return (zagu)(var3 == null ? zzk.a : this.a(var3));
   }

   public void f() {
      if (this.m != null) {
         this.m.b();
      } else {
         if (this.i) {
            if (this.k == this.j) {
               this.n = -1;
               return;
            }

            if (this.k > -1) {
               this.m = this.l.a(this.f + this.j, this.f + this.k, false);
            }
         } else {
            this.m = this.l.a(this.f, this.g, false);
            if (this.m == null) {
               this.i = true;
               return;
            }
         }

      }
   }

   public boolean b(int var1, int var2) {
      return this.a(var1);
   }

   public boolean a(int var1) {
      if (this.i) {
         if (var1 > this.k) {
            return false;
         }

         if (this.j == this.k) {
            this.n = -1;
            return true;
         }

         if (var1 < this.j) {
            var1 = this.j;
         }

         if (this.m == null) {
            this.m = this.l.a(this.f + this.j, this.f + this.k, false);
         }
      } else if (this.m == null) {
         this.m = this.l.a(this.f, this.g, false);
         if (this.m == null) {
            this.i = true;
            return false;
         }
      }

      this.m.a(var1 + this.f);
      return this.g();
   }

   public boolean g() {
      if (this.m == null) {
         if (this.j == this.k && this.n < this.j) {
            this.n = this.j;
            return true;
         } else {
            return false;
         }
      } else {
         zp var1;
         int var2;
         do {
            if (!this.m.hasNext()) {
               this.c = null;
               return false;
            }

            var1 = this.m.e();
            var2 = var1.b(this.h.a);
         } while(var2 <= -1 || var1.h(var2) == 0);

         this.n = var1.h() - this.f;
         this.c = var1.a(var2, this.h, this.e);
         this.d = null;
         return true;
      }
   }

   public int i() {
      return this.n;
   }

   public int j() {
      return 0;
   }

   public int k() {
      return this.n;
   }

   public zahn b(int var1) {
      return new zawm(this.b, this.a, this.c(var1, 0));
   }

   public zahn c(int var1) {
      return this;
   }

   public zahn c(zaay var1) {
      if (!this.i) {
         this.D();
      }

      if (this.k < 0) {
         return new zawz(zzk.a, 9, this.c(), 1);
      } else {
         zagu[] var2;
         if (this.j == this.k) {
            if (this.d == null) {
               this.d = this.C();
            }

            var2 = new zagu[]{this.d};
         } else {
            var2 = new zagu[this.k - this.j + 1];
            com.aspose.cells.a.c.zc.a(var2, 0, var2.length, zzk.a);
            if (this.m == null) {
               this.m = this.l.a(this.f + this.j, this.f + this.k, false);
            } else {
               this.m.b();
            }

            while(this.m.hasNext()) {
               zp var3 = this.m.e();
               if (var3.a() >= 1) {
                  int var4 = var3.b(this.h.a);
                  if (var4 >= 0 && var3.h(var4) != 0) {
                     zfv var5 = var3.a(var4, this.h, 4);
                     var2[var3.h() - this.f - this.j] = this.a(var5);
                  }
               }
            }

            if (this.n > -1) {
               this.m.a(this.n + 1);
            } else {
               this.m.b();
            }
         }

         return new zawg(var2, true, -this.j, this.c(), 9, zzk.a, -1, false);
      }
   }

   public boolean q() {
      return this.i;
   }

   public int r() {
      if (!this.i) {
         this.D();
      }

      return this.j;
   }

   public int s() {
      if (!this.i) {
         this.D();
      }

      return this.k;
   }

   public int t() {
      if (!this.i) {
         this.D();
      }

      return this.j < 0 ? -1 : 0;
   }

   public int u() {
      if (!this.i) {
         this.D();
      }

      return this.j < 0 ? -1 : 0;
   }

   public int v() {
      if (!this.i) {
         this.D();
      }

      return this.j;
   }

   public int w() {
      if (!this.i) {
         this.D();
      }

      return this.k;
   }

   private void D() {
      this.i = true;
      zahr var1 = this.l.a(this.f, this.g, false);

      while(var1.hasNext()) {
         zp var3 = var1.e();
         if (var3.a() >= 1) {
            int var2 = var3.b(this.h.a);
            if (var2 >= 0 && var3.h(var2) != 0) {
               this.j = var3.h();
               if (var1.hasNext()) {
                  zahr var4 = this.l.a(this.j + 1, this.g, true);

                  while(var4.hasNext()) {
                     zp var5 = var4.e();
                     if (var5.a() >= 1) {
                        int var6 = var5.b(this.h.a);
                        if (var6 >= 0 && var5.h(var6) != 0) {
                           this.k = var5.h();
                           if (this.j == this.f && this.k == this.g) {
                              this.m = var1;
                           } else if (this.m != null) {
                              this.m = this.l.a(this.j, this.k, false);
                              if (this.n > -1) {
                                 this.m.a(this.n + 1);
                              }
                           }

                           this.j -= this.f;
                           this.k -= this.f;
                           return;
                        }
                     }
                  }
               }

               this.j -= this.f;
               this.k = this.j;
               if (this.c == null) {
                  this.c = var3.a(var2, this.h, 7);
               }

               this.m = null;
               break;
            }
         }
      }

   }
}
